home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Extra 1997 #1 / Amiga Plus Extra 1997 #1.iso / programme / grafik / video easel / camrexx / digital.rexx < prev    next >
OS/2 REXX Batch file  |  1995-03-30  |  2KB  |  68 lines

  1. /* Digital Logic, by an idea of Toffoli, in CAMRexx by THOR */
  2.  
  3.  
  4. MakeAlgorithm:
  5.    if plane=0 then
  6.       PLANEALGORITHM margolus hvphases
  7.    if plane=1 then
  8.       PLANEALGORITHM echo center1
  9. return
  10.  
  11. MakePlane:
  12.    if plane=0 then; do                 /* calculate "electrons" */
  13.       wires=center_+cw_+ccw_+opp_      /* # of wires in plane 1 */
  14.  
  15.       if center_ then; do              /* Wire present here ? */
  16.          select
  17.             when wires=0 then
  18.                SETPLANE off            /* remove electron */
  19.             when wires=1 then; do
  20.                new=opp | cw | ccw      /* Origin nearby ? */
  21.                SETPLANE new            /* move electron to this wire */
  22.             end
  23.             when wires=2 then; do
  24.                                     /* fetch incoming signal */
  25.                if opp_ then signal=opp
  26.                if cw_ then signal=cw
  27.                if ccw_ then signal=ccw
  28.                if cw_ | ccw_ then
  29.                   signal=signal^opp
  30.                SETPLANE signal
  31.             end
  32.             when wires=3 then; do
  33.                i=1      /* read incoming signals */
  34.                if opp_ then; do
  35.                   signal.i=opp
  36.                   i=i+1
  37.                end
  38.                if cw_ then; do
  39.                   signal.i=cw
  40.                   i=i+1
  41.                end
  42.                if ccw_ then; do
  43.                   signal.i=ccw
  44.                   i=i+1
  45.                end
  46.                /* get logic control... */
  47.                if opp_=0 then
  48.                   control=opp
  49.                if cw_=0 then
  50.                   control=cw
  51.                if ccw_=0 then
  52.                   control=ccw
  53.  
  54.                if control then
  55.                   new=signal.1 & signal.2
  56.                else
  57.                   new=signal.1 | signal.2
  58.                SETPLANE new
  59.             end
  60.             when wires=4 then
  61.                SETPLANE opp            /* crossing */
  62.          end
  63.       end; else
  64.          SETPLANE center               /* preserve switches */
  65.    end
  66. return
  67.  
  68.